package com.zjb.demo.system.domain;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.zjb.demo.common.listener.BaseOnListener;
import com.zjb.demo.common.domain.dto.LogicalDeletionEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.noear.solon.validation.annotation.Email;
import org.noear.solon.validation.annotation.NotBlank;
import org.noear.solon.validation.annotation.NotNull;
import org.noear.solon.validation.annotation.Size;

import java.io.Serial;
import java.util.ArrayList;
import java.util.List;

/**
 * 部门表
 *
 * @author 庄佳彬
 * @since 2023/12/27 22:31
 */
@Table(value = "sys_dept", onInsert = BaseOnListener.class, onUpdate = BaseOnListener.class)
@ApiModel("部门表")
public class SysDept extends LogicalDeletionEntity {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 部门ID
     */
    @Id(keyType = KeyType.Generator, value = KeyGenerators.flexId)
    @Column(value = "dept_id")
    @ApiModelProperty("部门ID")
    private Long deptId;

    /**
     * 父部门ID
     */
    @Column(value = "parent_id")
    @ApiModelProperty("父部门ID")
    private Long parentId;

    /**
     * 祖级列表
     */
    @Column(value = "ancestors")
    @ApiModelProperty("祖级列表")
    private String ancestors;

    /**
     * 部门名称
     */
    @Column(value = "dept_name")
    @ApiModelProperty("部门名称")
    @NotBlank(message = "部门名称不能为空")
    @Size(max = 30, message = "部门名称长度不能超过30个字符")
    private String deptName;

    /**
     * 显示顺序
     */
    @Column(value = "order_num")
    @ApiModelProperty("显示顺序")
    @NotNull(message = "显示顺序不能为空")
    private Integer orderNum;

    /**
     * 负责人
     */
    @Column(value = "leader")
    @ApiModelProperty("负责人")
    private String leader;

    /**
     * 联系电话
     */
    @Column(value = "phone")
    @ApiModelProperty("联系电话")
    @Size(max = 11, message = "联系电话长度不能超过11个字符")
    private String phone;

    /**
     * 邮箱
     */
    @Column(value = "email")
    @ApiModelProperty("邮箱")
    @Email(message = "邮箱格式不正确")
    @Size(max = 50, message = "邮箱长度不能超过50个字符")
    private String email;

    /**
     * 部门状态:0正常,1停用
     */
    @Column(value = "status")
    @ApiModelProperty("部门状态:0正常,1停用")
    private String status;

    /**
     * 父部门名称
     */
    @Column(ignore = true)
    @ApiModelProperty("父部门名称")
    private String parentName;

    /**
     * 子部门
     */
    @Column(ignore = true)
    @ApiModelProperty("子部门")
    private final List<SysDept> children = new ArrayList<>();

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getAncestors() {
        return ancestors;
    }

    public void setAncestors(String ancestors) {
        this.ancestors = ancestors;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public Integer getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    public String getLeader() {
        return leader;
    }

    public void setLeader(String leader) {
        this.leader = leader;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public List<SysDept> getChildren() {
        return children;
    }




}
